import 'package:blue_plugin_example/base/get_common_view.dart';
import 'package:blue_plugin_example/bean/dev_info_init.dart';
import 'package:blue_plugin_example/controller/plug_route_sdk_niaoye_controller.dart';
import 'package:blue_plugin_example/res/colors.dart';
import 'package:blue_plugin_example/res/strings.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';

//插件路由
class PlugRouteNiaoYeSDK extends GetCommonView<PlugRouteNiaoYeSDKController> {
  PlugRouteNiaoYeSDK({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    Color textColor = ColorStyle.theme_text_color;
    TextEditingController _xtController = TextEditingController();
    _xtController.text = controller.xtEdit;

    return Scaffold(
        // resizeToAvoidBottomInset: false,
        appBar: AppBar(
            title: const Text("尿液SDK交互"),
            backgroundColor: ColorStyle.theme_text_color,
            leading: IconButton(
              icon: const Icon(
                Icons.arrow_back_ios,
                color: Colors.white,
              ),
              onPressed: () => {
                controller.sdkDestroyBlue(DevInfoInit.DEV_NIAOYE_NAME),
                Navigator.pop(context)
              }, // NavigatorUtil.back(),
            )),
        body: SingleChildScrollView(
          child: Column(
            children: [
              //血糖布局
              Row(
                mainAxisAlignment: MainAxisAlignment.center,
                crossAxisAlignment: CrossAxisAlignment.center,
                children: [
                  Container(
                    alignment: Alignment.center,
                    height: 210,
                    width: 360,
                    margin: const EdgeInsets.only(top: 10),
                    child: Stack(
                      alignment: Alignment.center,
                      children: [
                        const Image(
                            image: AssetImage(
                                "assets/images/1.0x/urine_analyzer.png")),
                        //指标
                        Positioned(
                            top: 32,
                            left: 46,
                            child: Container(
                                height: 114,
                                width: 230,
                                alignment: Alignment.topLeft,
                                child: Column(
                                  children: [
                                    //第一行
                                    Row(
                                      children: [
                                        //URO
                                        Flexible(
                                            fit: FlexFit.tight,
                                            flex: 1,
                                            child: Row(
                                              children: [
                                                Container(
                                                    alignment:
                                                        Alignment.center,
                                                    padding:const EdgeInsets.all(2),
                                                    margin: const EdgeInsets.only(right: 2),
                                                    height: 25,
                                                    width: 30,
                                                    decoration:
                                                        const BoxDecoration(
                                                      color: ColorStyle
                                                          .text_color_FFE49C2C,
                                                    ),
                                                    child: Row(
                                                      mainAxisAlignment: MainAxisAlignment.center,
                                                      children: const [
                                                        Text.rich(
                                                            TextSpan(children: [
                                                          TextSpan(
                                                              text: "URO",
                                                              style: TextStyle(
                                                                  fontSize: 10,
                                                                  color: ColorStyle
                                                                      .text_color_FFFCFCFC)),
                                                          TextSpan(
                                                            text: "\nμmol/L",
                                                            style: TextStyle(
                                                                fontSize: 6,
                                                                color: ColorStyle
                                                                    .text_color_FFFFDFAE),
                                                          ),
                                                        ])),
                                                      ],
                                                    )
                                                ),
                                                Text(
                                                  controller.tabURO,
                                                  style: const TextStyle(
                                                      fontSize: 18,
                                                      fontFamily: 'LESLIEB',
                                                      color: ColorStyle
                                                          .text_color_1E1F20),
                                                ),
                                              ],
                                            )),
                                        //LUE
                                        Flexible(
                                            fit: FlexFit.tight,
                                            flex: 1,
                                            child: Row(
                                              children: [
                                                Container(
                                                    alignment: Alignment.center,
                                                    padding:
                                                        const EdgeInsets.all(2),
                                                    margin: const EdgeInsets.only(right: 2),
                                                    height: 25,
                                                    width: 30,
                                                    decoration:
                                                        const BoxDecoration(
                                                      color: ColorStyle
                                                          .text_color_FFE49C2C,
                                                    ),
                                                    child: Row(
                                                      mainAxisAlignment: MainAxisAlignment.center,
                                                      children: const [
                                                        Text.rich(
                                                            TextSpan(children: [
                                                          TextSpan(
                                                              text: " LUE",
                                                              style: TextStyle(
                                                                  fontSize: 10,
                                                                  color: ColorStyle
                                                                      .text_color_FFFCFCFC)),
                                                          TextSpan(
                                                            text: "\ncells/μL",
                                                            style: TextStyle(
                                                                fontSize: 6,
                                                                color: ColorStyle
                                                                    .text_color_FFFFDFAE),
                                                          ),
                                                        ])),
                                                      ],
                                                    )),
                                                Text(
                                                  controller.tabLEU,
                                                  style: const TextStyle(
                                                      fontSize: 18,
                                                      fontFamily: 'LESLIEB',
                                                      color: ColorStyle
                                                          .text_color_1E1F20),
                                                )
                                              ],
                                            )),
                                        //NIT
                                        Flexible(
                                            fit: FlexFit.tight,
                                            flex: 1,
                                            child: Row(
                                              children: [
                                                Container(
                                                    alignment: Alignment.center,
                                                    padding:
                                                        const EdgeInsets.all(2),
                                                    margin: const EdgeInsets.only(right: 2),
                                                    height: 25,
                                                    width: 30,
                                                    decoration:
                                                        const BoxDecoration(
                                                      color: ColorStyle
                                                          .text_color_FFE49C2C,
                                                    ),
                                                    child: Row(
                                                      mainAxisAlignment: MainAxisAlignment.center,
                                                      children: const [
                                                        Text.rich(
                                                            TextSpan(children: [
                                                          TextSpan(
                                                              text: " NIT",
                                                              style: TextStyle(
                                                                  fontSize: 10,
                                                                  color: ColorStyle
                                                                      .text_color_FFFCFCFC)),
                                                          TextSpan(
                                                            text: "\nμmol/L",
                                                            style: TextStyle(
                                                                fontSize: 6,
                                                                color: ColorStyle
                                                                    .text_color_FFFFDFAE),
                                                          ),
                                                        ])),
                                                      ],
                                                    )),
                                                Text(
                                                  controller.tabNIT,
                                                  style: const TextStyle(
                                                      fontSize: 18,
                                                      fontFamily: 'LESLIEB',
                                                      color: ColorStyle
                                                          .text_color_1E1F20),
                                                )
                                              ],
                                            )),
                                      ],
                                    ),
                                    const SizedBox(
                                      height: 4,
                                    ),
                                    //第二行
                                    Row(
                                      children: [
                                        //BLD
                                        Flexible(
                                            fit: FlexFit.tight,
                                            flex: 1,
                                            child: Row(
                                              children: [
                                                Container(
                                                    alignment:
                                                        Alignment.topLeft,
                                                    padding:
                                                        const EdgeInsets.all(2),
                                                    margin: const EdgeInsets.only(right: 2),
                                                    height: 25,
                                                    width: 30,
                                                    decoration:
                                                        const BoxDecoration(
                                                      color: ColorStyle
                                                          .text_color_FFE49C2C,
                                                    ),
                                                    child: Row(
                                                      mainAxisAlignment: MainAxisAlignment.center,
                                                      children: const [
                                                        Text.rich(
                                                            TextSpan(children: [
                                                          TextSpan(
                                                              text: " BLD",
                                                              style: TextStyle(
                                                                  fontSize: 10,
                                                                  color: ColorStyle
                                                                      .text_color_FFFCFCFC)),
                                                          TextSpan(
                                                            text: "\ncells/μL",
                                                            style: TextStyle(
                                                                fontSize: 6,
                                                                color: ColorStyle
                                                                    .text_color_FFFFDFAE),
                                                          ),
                                                        ])),
                                                      ],
                                                    )),
                                                Text(
                                                  controller.tabBLD,
                                                  style: const TextStyle(
                                                      fontSize: 18,
                                                      fontFamily: 'LESLIEB',
                                                      color: ColorStyle
                                                          .text_color_1E1F20),
                                                ),
                                              ],
                                            )),
                                        //GLU
                                        Flexible(
                                            fit: FlexFit.tight,
                                            flex: 1,
                                            child: Row(
                                              children: [
                                                Container(
                                                    alignment: Alignment.center,
                                                    padding:
                                                        const EdgeInsets.all(2),
                                                    margin: const EdgeInsets.only(right: 2),
                                                    height: 25,
                                                    width: 30,
                                                    decoration:
                                                        const BoxDecoration(
                                                      color: ColorStyle
                                                          .text_color_FFE49C2C,
                                                    ),
                                                    child: Row(
                                                      mainAxisAlignment: MainAxisAlignment.center,
                                                      children: const [
                                                        Text.rich(
                                                            TextSpan(children: [
                                                          TextSpan(
                                                              text: " GLU",
                                                              style: TextStyle(
                                                                  fontSize: 10,
                                                                  color: ColorStyle
                                                                      .text_color_FFFCFCFC)),
                                                          TextSpan(
                                                            text: "\nmmol/L",
                                                            style: TextStyle(
                                                                fontSize: 6,
                                                                color: ColorStyle
                                                                    .text_color_FFFFDFAE),
                                                          ),
                                                        ])),
                                                      ],
                                                    )),
                                                Text(
                                                  controller.tabGLU,
                                                  style: const TextStyle(
                                                      fontSize: 18,
                                                      fontFamily: 'LESLIEB',
                                                      color: ColorStyle
                                                          .text_color_1E1F20),
                                                )
                                              ],
                                            )),
                                        //SG
                                        Flexible(
                                            fit: FlexFit.tight,
                                            flex: 1,
                                            child: Row(
                                              children: [
                                                Container(
                                                    alignment: Alignment.center,
                                                    padding:
                                                        const EdgeInsets.all(2),
                                                    margin: const EdgeInsets.only(right: 2),
                                                    height: 25,
                                                    width: 30,
                                                    decoration:
                                                        const BoxDecoration(
                                                      color: ColorStyle
                                                          .text_color_FFE49C2C,
                                                    ),
                                                    child: Row(
                                                      mainAxisAlignment: MainAxisAlignment.center,
                                                      children: const [
                                                        Text.rich(
                                                            TextSpan(children: [
                                                          TextSpan(
                                                              text: "SG",
                                                              style: TextStyle(
                                                                  fontSize: 10,
                                                                  color: ColorStyle
                                                                      .text_color_FFFCFCFC)),
                                                        ])),
                                                      ],
                                                    )),
                                                Text(
                                                  controller.tabSG,
                                                  style: const TextStyle(
                                                      fontSize: 18,
                                                      fontFamily: 'LESLIEB',
                                                      color: ColorStyle
                                                          .text_color_1E1F20),
                                                )
                                              ],
                                            )),
                                      ],
                                    ),
                                    const SizedBox(
                                      height: 4,
                                    ),
                                    //第三行
                                    Row(
                                      children: [
                                        //BIL
                                        Flexible(
                                            fit: FlexFit.tight,
                                            flex: 1,
                                            child: Row(
                                              children: [
                                                Container(
                                                    alignment:
                                                        Alignment.topLeft,
                                                    padding:
                                                        const EdgeInsets.all(2),
                                                    margin: const EdgeInsets.only(right: 2),
                                                    height: 25,
                                                    width: 30,
                                                    decoration:
                                                        const BoxDecoration(
                                                      color: ColorStyle
                                                          .text_color_FFE49C2C,
                                                    ),
                                                    child: Row(
                                                      mainAxisAlignment: MainAxisAlignment.center,
                                                      children: const [
                                                        Text.rich(
                                                            TextSpan(children: [
                                                          TextSpan(
                                                              text: " BIL",
                                                              style: TextStyle(
                                                                  fontSize: 10,
                                                                  color: ColorStyle
                                                                      .text_color_FFFCFCFC)),
                                                          TextSpan(
                                                            text: "\nμmol/L",
                                                            style: TextStyle(
                                                                fontSize: 6,
                                                                color: ColorStyle
                                                                    .text_color_FFFFDFAE),
                                                          ),
                                                        ])),
                                                      ],
                                                    )),
                                                Text(
                                                  controller.tabBIL,
                                                  style: const TextStyle(
                                                      fontSize: 18,
                                                      fontFamily: 'LESLIEB',
                                                      color: ColorStyle
                                                          .text_color_1E1F20),
                                                ),
                                              ],
                                            )),
                                        //PRO
                                        Flexible(
                                            fit: FlexFit.tight,
                                            flex: 1,
                                            child: Row(
                                              children: [
                                                Container(
                                                    alignment: Alignment.center,
                                                    padding:
                                                        const EdgeInsets.all(2),
                                                    margin: const EdgeInsets.only(right: 2),
                                                    height: 25,
                                                    width: 30,
                                                    decoration:
                                                        const BoxDecoration(
                                                      color: ColorStyle
                                                          .text_color_FFE49C2C,
                                                    ),
                                                    child: Row(
                                                      mainAxisAlignment: MainAxisAlignment.center,
                                                      children: const [
                                                        Text.rich(
                                                            TextSpan(children: [
                                                          TextSpan(
                                                              text: " PRO",
                                                              style: TextStyle(
                                                                  fontSize: 10,
                                                                  color: ColorStyle
                                                                      .text_color_FFFCFCFC)),
                                                          TextSpan(
                                                            text: "\n    g/L",
                                                            style: TextStyle(
                                                                fontSize: 6,
                                                                color: ColorStyle
                                                                    .text_color_FFFFDFAE),
                                                          ),
                                                        ])),
                                                      ],
                                                    )),
                                                Text(
                                                  controller.tabPRO,
                                                  style: const TextStyle(
                                                      fontSize: 18,
                                                      fontFamily: 'LESLIEB',
                                                      color: ColorStyle
                                                          .text_color_1E1F20),
                                                )
                                              ],
                                            )),
                                        //VC
                                        Flexible(
                                            fit: FlexFit.tight,
                                            flex: 1,
                                            child: Row(
                                              children: [
                                                Container(
                                                    alignment: Alignment.center,
                                                    padding:
                                                        const EdgeInsets.all(2),
                                                    margin: const EdgeInsets.only(right: 2),
                                                    height: 25,
                                                    width: 30,
                                                    decoration:
                                                        const BoxDecoration(
                                                      color: ColorStyle
                                                          .text_color_FFE49C2C,
                                                    ),
                                                    child: Row(
                                                      mainAxisAlignment: MainAxisAlignment.center,
                                                      children: const [
                                                        Text.rich(
                                                            TextSpan(children: [
                                                          TextSpan(
                                                              text: " VC",
                                                              style: TextStyle(
                                                                  fontSize: 10,
                                                                  color: ColorStyle
                                                                      .text_color_FFFCFCFC)),
                                                          TextSpan(
                                                            text: "\nmmol/L",
                                                            style: TextStyle(
                                                                fontSize: 6,
                                                                color: ColorStyle
                                                                    .text_color_FFFFDFAE),
                                                          ),
                                                        ])),
                                                      ],
                                                    )),
                                                Text(
                                                  controller.tabVC,
                                                  style: const TextStyle(
                                                      fontSize: 18,
                                                      fontFamily: 'LESLIEB',
                                                      color: ColorStyle
                                                          .text_color_1E1F20),
                                                )
                                              ],
                                            )),
                                      ],
                                    ),
                                    const SizedBox(
                                      height: 4,
                                    ),
                                    //第四行
                                    Row(
                                      children: [
                                        //KET
                                        Flexible(
                                            fit: FlexFit.tight,
                                            flex: 1,
                                            child: Row(
                                              children: [
                                                Container(
                                                    alignment:
                                                        Alignment.center,
                                                    padding:
                                                        const EdgeInsets.all(2),
                                                    margin: const EdgeInsets.only(right: 2),
                                                    height: 25,
                                                    width: 30,
                                                    decoration:
                                                        const BoxDecoration(
                                                      color: ColorStyle
                                                          .text_color_FFE49C2C,
                                                    ),
                                                    child: Row(
                                                      mainAxisAlignment: MainAxisAlignment.center,
                                                      children: const [
                                                        Text.rich(
                                                            TextSpan(children: [
                                                          TextSpan(
                                                              text: " KET",
                                                              style: TextStyle(
                                                                  fontSize: 10,
                                                                  color: ColorStyle
                                                                      .text_color_FFFCFCFC)),
                                                          TextSpan(
                                                            text: "\nmmol/L",
                                                            style: TextStyle(
                                                                fontSize: 6,
                                                                color: ColorStyle
                                                                    .text_color_FFFFDFAE),
                                                          ),
                                                        ])),
                                                      ],
                                                    )),
                                                Text(
                                                  controller.tabKET,
                                                  style: const TextStyle(
                                                      fontSize: 18,
                                                      fontFamily: 'LESLIEB',
                                                      color: ColorStyle
                                                          .text_color_1E1F20),
                                                ),
                                              ],
                                            )),
                                        //PH
                                        Flexible(
                                            fit: FlexFit.tight,
                                            flex: 1,
                                            child: Row(
                                              children: [
                                                Container(
                                                    alignment:Alignment.center,
                                                    padding:
                                                        const EdgeInsets.all(2),
                                                    margin: const EdgeInsets.only(right: 2),
                                                    height: 25,
                                                    width: 30,
                                                    decoration:
                                                        const BoxDecoration(
                                                      color: ColorStyle
                                                          .text_color_FFE49C2C,
                                                    ),
                                                    child: Row(
                                                      mainAxisAlignment: MainAxisAlignment.center,
                                                      children: const [
                                                        Text.rich(
                                                            TextSpan(children: [
                                                          TextSpan(
                                                              text: "PH",
                                                              style: TextStyle(
                                                                  fontSize: 10,
                                                                  color: ColorStyle
                                                                      .text_color_FFFCFCFC)),
                                                        ])),
                                                      ],
                                                    )),
                                                Text(
                                                  controller.tabPH,
                                                  style: const TextStyle(
                                                      fontSize: 18,
                                                      fontFamily: 'LESLIEB',
                                                      color: ColorStyle
                                                          .text_color_1E1F20),
                                                )
                                              ],
                                            )),
                                        //VC
                                        Flexible(
                                            fit: FlexFit.tight,
                                            flex: 1,
                                            child: Row(
                                              children: [
                                              ],
                                            )),
                                      ],
                                    ),
                                  ],
                                ))),


                        //连接的背景图片
                        Positioned(
                            top: 45,
                            right: 22,
                            child: Container(
                              alignment: Alignment.center,
                              width: 54,
                              height: 54,
                              child: InkWell(
                                child: const Image(
                                  image: AssetImage(
                                      "assets/images/1.0x/btn_xyy_click.png"),
                                ),
                                onTap: () => controller.onConnectBtn(),
                              )
                            )),

                        //连接按钮的文字
                        Positioned(
                          top: 45,
                          right: 22,
                          child: Container(
                            alignment: Alignment.center,
                            width: 54,
                            height: 54,
                            child: InkWell(
                              child: Text(
                                controller.connectMsg,
                                style: TextStyle(color: textColor),
                              ),
                              onTap: () => controller.onConnectBtn(),
                            ),
                          )
                        ),
                      ],
                    ),
                  )
                ],
              ),
              //提示文案
              Container(
                margin: const EdgeInsets.only(left: 12, right: 12),
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: const [
                    Text(
                      StringStyles.niaoyeHint,
                      style: TextStyle(
                          fontSize: 14, color: ColorStyle.text_color_FE9870),
                    ),
                  ],
                ),
              ),

              //表格
              Container(
                margin: const EdgeInsets.only(left: 12, right: 12, top: 20),
                decoration: const BoxDecoration(
                  color: ColorStyle.color_white,
                ),
                child: Column(
                  children: [
                    // 表头
                    Container(
                        padding: const EdgeInsets.only(left: 12),
                        decoration: const BoxDecoration(
                          color: ColorStyle.color_btn_bg,
                        ),
                        height: 50,
                        child: Row(
                          children: const [
                            // 占位
                            Flexible(
                                fit: FlexFit.tight,
                                flex: 1,
                                child: Text("采集指标",
                                    style: TextStyle(
                                        fontSize: 14,
                                        color: ColorStyle.text_color_1E1F20))),

                            Flexible(
                                fit: FlexFit.tight,
                                flex: 1,
                                child: Text("采集数值",
                                    style: TextStyle(
                                        fontSize: 14,
                                        color: ColorStyle.text_color_1E1F20))),
                            Flexible(
                                fit: FlexFit.tight,
                                flex: 1,
                                child: Text("采集指标",
                                    style: TextStyle(
                                        fontSize: 14,
                                        color: ColorStyle.text_color_1E1F20))),
                            Flexible(
                                fit: FlexFit.tight,
                                flex: 1,
                                child: Text("采集数值",
                                    style: TextStyle(
                                        fontSize: 14,
                                        color: ColorStyle.text_color_1E1F20))),
                          ],
                        )),
                    //表格体
                    Container(
                        margin: const EdgeInsets.only(top: 10.0),
                        height: 48,
                        child: Row(
                          children: [
                            // //占位
                            // Flexible(
                            //     fit: FlexFit.tight,
                            //     flex: 1,
                            //     child: Container(
                            //       margin: const EdgeInsets.only(left: 10),
                            //     )),
                            // //血糖输入
                            // Flexible(
                            //     fit: FlexFit.tight,
                            //     flex: 1,
                            //     child: Container(
                            //       margin: const EdgeInsets.only(left: 10),
                            //       child: TextField(
                            //         controller: _xtController,
                            //         style: const TextStyle(fontSize: 18),
                            //         keyboardType: TextInputType.number,
                            //         textAlign: TextAlign.center,
                            //         decoration: const InputDecoration(
                            //             contentPadding: EdgeInsets.only(
                            //                 top: 0, bottom: 0, left: 4),
                            //             border: OutlineInputBorder(),
                            //             hintText: "请输入",
                            //             hintMaxLines: 1,
                            //             labelStyle: TextStyle(
                            //                 color: ColorStyle
                            //                     .text_color_1E1F20_45)),
                            //       ),
                            //     )),
                            // //占位
                            // Flexible(
                            //     fit: FlexFit.tight,
                            //     flex: 1,
                            //     child: Container(
                            //       margin: const EdgeInsets.only(left: 10),
                            //     )),
                          ],
                        )),
                  ],
                ),
              ),

              const SizedBox(
                height: 100,
              ),
              //底部按钮
              GestureDetector(
                child: Container(
                  height: 48,
                  alignment: Alignment.center,
                  decoration: BoxDecoration(
                    color: controller.btnColor,
                    //设置四周圆角 角度
                    borderRadius: const BorderRadius.all(Radius.circular(8.0)),
//                      设置四周边框
                    // border: new Border.all(width: 1, color: ColorStyle.theme_text_color),
                  ),
                  margin:
                      const EdgeInsets.only(left: 12, right: 12, bottom: 30),
                  child: const Text("提交",
                      style: TextStyle(
                          color: ColorStyle.color_white, fontSize: 16)),
                ),
                onTap: () => controller.onUpDataBtn(),
              ),
            ],
          ),
        ));
  }
}
